<template>
  <a-upload
      v-model:file-list="fileList"
      :action="host+'/api/v1/uploat'"
      :headers="headers"
      name="file"
      @change="handleChange"
  >
    <a-button>
      <upload-outlined></upload-outlined>
      封面
    </a-button>
  </a-upload>
  <a-upload
      v-model:file-list="fileList2"
      :action="host+'/api/v1/uploat'"
      :headers="headers"
      name="file"
      @change="handleChange"
  >
    <a-button>
      <upload-outlined></upload-outlined>
      视频
    </a-button>
  </a-upload>
  <a-input v-model:value="value" placeholder="Basic usage"/>
  <a-button type="primary" @click="submit">上传</a-button>
  <br>
  {{ fileList }} <br>
  {{ fileList2 }} <br>
  {{ value }} <br>

  <!--  <video src="http://192.168.100.17/upload/files/202308/mda-pef24shghgdkhtka64ddb4417b8fd_64ddb441.mp4"-->
  <!--         class="mainVideo" controls="controls"></video>-->
  <!--  <video src="http://192.168.100.17/upload/files/202308/mda-pef24shghgdkhtka64ddb4417b8fd_64ddb441.mp4"-->
  <!--         class="mainVideo" controls="controls"></video>-->
  <!--  <video src="http://192.168.100.17/upload/files/202308/mda-pef24shghgdkhtka64ddb4417b8fd_64ddb441.mp4"-->
  <!--         class="mainVideo" controls="controls"></video>-->
  <!--  <video src="http://192.168.100.17/upload/files/202308/mda-pef24shghgdkhtka64ddb4417b8fd_64ddb441.mp4"-->
  <!--         class="mainVideo" controls="controls"></video>-->
  <a-input v-model:value="codevalue" placeholder="Basic usage"/>

  <a-button type="primary" @click="deencode">解密</a-button>
  <a-button type="primary" @click="encode">加密</a-button>
  {{ mima }}
  <br>
  {{ jiemi }}
</template>

<script setup>
import {ref} from "@vue/reactivity";
import {message} from "ant-design-vue";
import {host} from "@/configs/run";
import {VideoAdd} from "@/common/customs/setting";
import {decodeAesString, encodeAesString} from "@/common/crypto";

const fileList = ref([]);
const fileList2 = ref([]);
const value = ref("");
const codevalue = ref("");
const handleChange = (info) => {
  if (info.file.status !== "uploading") {
    console.log(info.file, info.fileList);
  }
  if (info.file.status === "done") {
    message.success(`${info.file.name} file uploaded successfully`);
  } else if (info.file.status === "error") {
    message.error(`${info.file.name} file upload failed.`);
  }
};
const headers = {
  authorization: "authorization-text",
};
const submit = async () => {
  console.log(fileList.value, fileList2.value, value.value);
  const api = new VideoAdd();
  api.data({
    name: value.value,
    sp: fileList2.value[0].response.data,
    img: fileList.value[0].response.data
  });
  await api.send();
  const {data} = await api.getDatas();
  console.log(data);
};
const mima = ref("");
const jiemi = ref("");
const deencode = () => {

  let str = decodeAesString(codevalue.value);
  jiemi.value = str;
  codevalue.value = str;
  console.log(str);
};

const encode = () => {
  let str = encodeAesString(codevalue.value);
  mima.value = str;
  codevalue.value = str;
  console.log(str);
};
</script>

<style scoped>

</style>
